//获取校区名字
import { schoolNameGet,subjectGet } from "../api/student"
import { schoolType } from "../types/schoolType"
import {objType} from '../types/examType'

//异步函数，在调用的时候要加await
export const getSchoolName = async () => {
    let obj:objType = {}
    let res = await schoolNameGet()
    let resData = res.data.results as schoolType[]
    resData.forEach(item => {
        obj[item.objectId] = item.schoolName
    });
    return obj
}

//获取科目名称
interface subjectType{
    objectId:string;
    subject:string;
}
export const getSubjectName = async () => {
    let obj:objType = {}
    let res = await subjectGet("0-0") 
    let resData = res.data.results as subjectType[]
    resData.forEach(item => {
        obj[item.objectId] = item.subject
    });
    return obj
}